home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / PTIMER.ASM < prev    next >
Assembly Source File  |  1980-01-01  |  4KB  |  134 lines

  1.  
  2.         TITLE   PTIMER.ASM (or CPU.ASM)
  3.  
  4. ;
  5. ;       Programmer: Unknown
  6. ;       DisAssembled by Dave Hoo    09-25-85
  7. ;
  8.  
  9. LF      EQU     0AH
  10. CR      EQU     0DH
  11.  
  12. code    SEGMENT
  13.         ASSUME  CS:code,DS:code,ES:code
  14.         ORG     100H
  15. start:  MOV     AH,9
  16.         MOV     DX,OFFSET banner
  17.         INT     21H
  18.         MOV     AH,2CH
  19.         INT     21H
  20. ;                                     clocks needed
  21. ;--------------------------------------------------
  22.         MOV  OldSec,DX ; 19              =       19
  23.         XOR  AX,AX     ;  3              =        3
  24.         MOV  DX,10     ;  4              =        4
  25. outer:  MOV  CX,47227  ;  4         * 10 =       40
  26. inner:  AAM            ; 83 * 47227 * 10 = 39198410   (  1.98 % )
  27.         DEC  CX        ;  2 * 47227 * 10 =   944540   (  1.98 % )
  28.         JNZ  inner     ; 16 * 47226 * 10 +
  29.                        ;  4         * 10 =  7556200   ( 15.84 % )
  30.         DEC  DX        ;  2         * 10 =       20
  31.         JNZ  outer     ; 16         *  9 +
  32.                        ;  4              =      148
  33.         MOV  AH,2CH    ;  4              =        4
  34.         INT     21H
  35. ;--------------------------------------------------
  36. ;                        T O T A L       = 47699388 + INT GetTime
  37. ;                        or                4.77E+06 * 10
  38.  
  39. ;
  40. ;If following statements is for NEC V-20 running 4.77 Mhz, then it means
  41. ;NEC V-20 only needs 15980000 clocks instead of 47699388.
  42. ;
  43. ;   "Actual execution time here was 03.35 seconds
  44. ;    Effective clock speed = >.23 Mhz"
  45. ;                          (14.23 Mhz)
  46. ;
  47. ;It will not surprise me if NEC V-20 had reduced the clocks
  48. ;needed for AAM instruction to 20.
  49. ;
  50. ;But AAM is a rarely used insturction, even in this program when there
  51. ;is a chance to really use AAM the programmer chose IDIV instead. (see EX:)
  52. ;
  53.         MOV     AX,100
  54.         IMUL    DH
  55.         MOV     DH,0
  56.         ADD     AX,DX                  ;seconds(after)  * 100  [0..5999]
  57.         MOV     BX,AX
  58.         MOV     DX,OldSec
  59.         MOV     AX,100
  60.         IMUL    DH
  61.         MOV     DH,0
  62.         ADD     AX,DX                  ;seconds(before) * 100  [0..5999]
  63.         SUB     BX,AX
  64.         JNB     SameM                  ;within same minute, no adjustment
  65.         ADD     BX,6000                ;otherwise add 1 minute
  66. SameM:  MOV     AX,BX
  67.         MOV     DifSec,BX
  68.         MOV     BP,offset ACTsec
  69.         MOV     BX,1000
  70.         CWD
  71.         IDIV    BX                     ;dx:ax / 1000
  72.         CALL    ToASC                  ;get first digit
  73.         MOV     BX,100
  74.         MOV     AX,DX
  75.         CWD
  76.         IDIV    BX
  77.         CALL    ToASC                  ;get second digit
  78.         INC     BP                     ;skip decimal point
  79.         MOV     BX,10
  80.         MOV     AX,DX
  81.         CWD
  82. EX:     IDIV    BX
  83.         CALL    ToASC                  ;first digit after decimal point
  84.         MOV     AX,DX
  85.         CALL    ToASC                  ;last digit after decimal point
  86.         MOV     AH,9
  87.         MOV     DX,OFFSET EXCmsg
  88.         INT     21H
  89.         MOV     AX,4770
  90.         CWD
  91.         MOV     BX,DifSec
  92.         DIV     BX
  93.         MOV     BP,offset EFFclk
  94.         CALL    ToASC                  ;get one digit
  95.         INC     BP                     ;skip decimal point
  96.         MOV     AX,DX
  97.         MOV     CX,10
  98.         MUL     CX                     ;remainder * 10
  99.         DIV     BX
  100.         CALL    ToASC
  101.         MOV     AX,DX
  102.         MUL     CX                     ;remainder * 10
  103.         DIV     BX
  104.         CALL    ToASC
  105.         MOV     AH,9
  106.         MOV     DX,OFFSET EFFmsg
  107.         INT     21H
  108.         MOV     AH,4CH                 ;terminate with '$'
  109.         INT     21H                    ;as return code
  110.  
  111. ToASC   proc    near
  112.         OR      AL,30H
  113.         MOV     [BP],AL
  114.         INC     BP
  115.         ret
  116. ToASC   endp
  117.  
  118. OldSec  DW      0
  119. DifSec  DW      0
  120.  
  121. Banner  DB      'CLOCK SPEED CHECKER (minimal RAM access), please wait...'
  122.         DB      CR,LF,'$'
  123. EXCmsg  DB      'Execution time should be 10.00 secs if 4.77 Mhz clock'
  124.         DB      ' & no WAITs on RAM access',CR,LF
  125.         DB      'Actual execution time here was '
  126. ACTsec  DB      '00.00 seconds',CR,LF,'$'
  127. EFFmsg  DB      'Effective clock speed = '
  128. EFFclk  DB      '0.00 Mhz',CR,LF,'$'
  129.  
  130. code    ENDS
  131. ;
  132.         END   start
  133. END OF TRANSFER - PRESS ENTER TO RETURN TO MENU
  134.